import request from '@utils/request'
import axios from 'axios'
import config from '@/config'

// 登录
const login = async (data) => {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

// 注册
const register = async (data) => {
  return request({
    url: '/user/register',
    method: 'post',
    data
  })
}

// 获取用户列表
const getUsers = (data) => {
  return request({
    url: '/user/admin/findUsers',
    method: 'get',
    data
  })
}

// 删除用户
const removeUsers = (data) => {
  return request({
    url: '/user/admin/removeUsers',
    method: 'get',
    data
  })
}

// 新增用户
// const adminAddUsers = (option: any) => {
//   return axios.post("/user/admin/adminAddUsers", {
//     ...option,
//   });
// };

// 重置密码
const resetPwd = (data) => {
  return request({
    url: '/user/resetPwd',
    method: 'post',
    data
  })
}

// 更新用户
const adminUpdateUsers = (data) => {
  return request({
    url: '/user/admin/adminUpdateUsers',
    method: 'post',
    data
  })
}

// 修改资料
const resetInfo = (data) => {
  return request({
    url: '/user/resetInfo',
    method: 'post',
    data
  })
}

// 忘记密码
const forgotPwd = (data) => {
  return request({
    url: '/user/forgotPwd',
    method: 'post',
    data
  })
}

// 获取用户简易信息
const getUserInfoMin = (data) => {
  return axios.get(`${config.server.backServer}/user/getUserInfoMin?userid=${data.userid}`)
}

export { login, register, getUsers, removeUsers, resetPwd, adminUpdateUsers, resetInfo, forgotPwd, getUserInfoMin }
